package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.domain.CommentInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.service.ICommentInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户评论信息Controller
 *
 * @author jiabao
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/comment")
public class CommentInfoController extends BaseController
{
    @Autowired
    private ICommentInfoService commentInfoService;

    /**
     * 查询用户评论信息列表
     */
    @RequiresPermissions("system:comment:list")
    @GetMapping("/list")
    public TableDataInfo list(CommentInfo commentInfo)
    {
        startPage();
        List<CommentInfo> list = commentInfoService.selectCommentInfoList(commentInfo);
        return getDataTable(list);
    }



    /**
     * 获取用户评论信息详细信息
     */
    @RequiresPermissions("system:comment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(commentInfoService.selectCommentInfoById(id));
    }


    /**
     * 审核通过
     */
    @PostMapping("/reviewTrue")
    public AjaxResult reviewTrue(@RequestBody CommentInfo commentInfo) {
        if (commentInfo.getOrderNo() == null) {
            return AjaxResult.error("订单号不能为空");
        }
        return commentInfoService.reviewTrue(commentInfo.getOrderNo());

    }

    /**
     * 审核驳回
     */
    @PostMapping("/reviewFalse")
    public AjaxResult reviewFalse(@RequestBody CommentInfo commentInfo) {
        if (commentInfo.getOrderNo() == null) {
            return AjaxResult.error("订单号不能为空");
        }
        if (commentInfo.getReviewStatusDesc() == null || commentInfo.getReviewStatusDesc().trim().isEmpty()) {
            return AjaxResult.error("驳回理由不能为空");
        }
        return commentInfoService.reviewFalse(commentInfo.getOrderNo(), commentInfo.getReviewStatusDesc());

    }







}
